<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="com.wap.framework.util.Constants;"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath + "admin" + "/"%>">
		<title>用户管理</title>
		<link rel="stylesheet" type="text/css"
			href="skin/css/base.css">
		<script language="javascript" type="text/javascript"
			src="skin/js/frame/dynamic_page.js"></script>
		<script type="text/javascript">
			function statusMgr()
			{
				var count = 0;
				var ids = document.getElementsByName('id');				
				for(var i = 0; i < ids.length; i++)
				{
					if(ids[i].type == 'checkbox' && ids[i].checked)
					{						
						count++;
					}
				}
				if(count == 0)
				{
					alert("至少选择一项!");
					return;
				}						
				
				document.userFM.action = "<%=path%>/admin/userMgr.do?action_method=update";
				document.userFM.target = "main";
				document.userFM.submit();
			}		
		
			function submitPageNum()
			{
				var pageNo = document.userFM.pageNum.value;
				var state  = document.userFM.status.value;
				var method;
				if(state < 0)
				{
					method = "list";
				}else
				{
					method = "listByStatus";
				}
				document.userFM.action = "<%=path%>/admin/userMgr.do?action_method="+method+"&currentPage="+pageNo;
				document.userFM.target = "main";
				document.userFM.submit();
			}
			
			function listByStatus()
			{
				document.userFM.action = "<%=path%>/admin/userMgr.do?action_method=listByStatus";
				document.userFM.target = "main";
				document.userFM.submit();
			}
		</script>		
	</head>
	<body leftmargin="8" topmargin="8" background='skin/images/allbg.gif'>
		<!--  用户列表   -->
		<form name="userFM" method="post">
			<input type="hidden" name="action_method" value="delete">
			<table width="98%" border="0" cellpadding="2" cellspacing="1"
				bgcolor="#D1DDAA" align="center" style="margin-top: 8px">
				<tr bgcolor="#E7E7E7">
					<td height="24" colspan="11" background="skin/images/tbg.gif">
						&nbsp;用户列表&nbsp;
						<select name="status" onchange="listByStatus()">						
							<option value="-1" <c:if test="${state == -1}">selected</c:if> >全部用户</option>
							<option value="1"  <c:if test="${state == 1}">selected</c:if> >已激活</option>
							<option value="0" <c:if test="${state == 0}">selected</c:if>>未激活</option>							
						</select>
					</td>					
				</tr>
				<tr align="center" bgcolor="#FAFAF1" height="22">
					<td width="3%">
						选择
					</td>
					<td width="4%">
						ID
					</td>
					<td width="6%">
						用户名
					</td>
					<td width="6%">
						手机号码
					</td>
					<td width="4%">
						性别
					</td>
					<td width="4%">
						年龄
					</td>
					<td width="8%">
						e-mail
					</td>
					<td width="4%">
						状态
					</td>
					<td width="4%">
						积分
					</td>
					<td width="5%">
						更新到缓存
					</td>
					<td width="3%">
						操作
					</td>
				</tr>
				<c:forEach items="${users}" var="userColl">
					<tr align='center' bgcolor="#FFFFFF"
						onMouseMove="javascript:this.bgColor='#FCFDEE';"
						onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">						
						<td>
							<c:if test="${state == 0}">
								<c:set value="1" var="updateValue"/>
							</c:if>
							<c:if test="${state == 1}">
								<c:set value="0" var="updateValue"/>
							</c:if>
							<input name="id" type="checkbox" value="${userColl.uid}@${updateValue}"
								class="np">
						</td>
						<td>
							${userColl.uid}
						</td>
						<td align="left">
							${userColl.username}							
						</td>
						<td>
							${userColl.cellPhone}
						</td>
						<td>
							<c:if test="${userColl.sex eq 'M'}">
								男
							</c:if>
							<c:if test="${userColl.sex eq 'F'}">
								女
							</c:if>
						</td>
						<td>
							${userColl.age}
						</td>
						<td align="left">
							${userColl.email}
						</td>
						<td>
							<c:if test="${userColl.status == 0}">
								未激活
							</c:if>
							<c:if test="${userColl.status == 1}">
								已激活
							</c:if>
						</td>
						<td>
							${userColl.score}
						</td>
						<td>
							<a href="<%=Constants.WAPSITE_PATH%>/update_cache.jsp?cmd=updatePageObjectById&pageid=${contentColl.id}" >更新</a>
						</td>
						<td>
							<c:if test="${userColl.status == 0}">
								<a href="<%=path%>/admin/userMgr.do?action_method=update&id=${userColl.uid}@${userColl.status + 1}"
								target='main'>激活</a>
							</c:if>
							<c:if test="${userColl.status == 1}">
								<a href="<%=path%>/admin/userMgr.do?action_method=update&id=${userColl.uid}@${userColl.status - 1}"
								target='main'>锁定</a>
							</c:if>							
						</td>
					</tr>
				</c:forEach>

				<tr bgcolor="#FAFAF1">
					<td height="28" colspan="11">
						&nbsp;
						<input class="coolbg" type="button" value="全选" onclick="selAll()" />
						<input class="coolbg" type="button" value="取消"
							onclick="noSelAll()" />
						<c:if test="${state == 0}">
							<input class="coolbg" type="button" value="激活" onclick="statusMgr()" />
						</c:if>
						<c:if test="${state == 1}">
							<input class="coolbg" type="button" value="锁定" onclick="statusMgr()" />
						</c:if>
						<input class="coolbg" type="button" value="删除"
							onclick="doDelete()" />
					</td>
				</tr>

				<tr align="right" bgcolor="#EEF4EA">
					<td height="25" colspan="11" align="right">
						<table>
							<tr>
								<td>
									<c:if test="${pageHelper.currentPage > 1}">
										<a
											href="<%=path%>/admin/userMgr.do?action_method=${method}&currentPage=1"
											target='main'>第一页</a>
									</c:if>
									<c:if test="${pageHelper.currentPage > 1}">
										<a
											href="<%=path%>/admin/userMgr.do?action_method=${method}&currentPage=${pageHelper.currentPage - 1}"
											target='main'>上一页</a>
									</c:if>
									<c:if test="${pageHelper.currentPage < pageHelper.totalPages}">
										<a
											href="<%=path%>/admin/userMgr.do?action_method=${method}&currentPage=${pageHelper.currentPage + 1}"
											target='main'>下一页</a>
									</c:if>
									<c:if test="${pageHelper.currentPage < pageHelper.totalPages}">
										<a
											href="<%=path%>/admin/userMgr.do?action_method=${method}&currentPage=${pageHelper.totalPages}"
											target='main'>最后页</a>
									</c:if>
									<span>[&nbsp;第${pageHelper.currentPage}页&nbsp;/&nbsp;共${pageHelper.totalPages}页&nbsp;]</span>
								</td>
								<td>
									<span> 
										<select name="pageNum" onchange="submitPageNum()">
												<c:forEach var="tmp" begin="1" end="${pageHelper.totalPages}">
													<option value="${tmp}"
														<c:if test="${pageHelper.currentPage == tmp}">selected</c:if>>
														第${tmp}页
													</option>
												</c:forEach>
										</select>
									</span>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</form>
	</body>
</html>
